Step 11: PUT Request

Let's include a route to update a bookmark.

HTTP MethodPUT
API Endpoint/bookmarks/:id
Request Path Parameterid
Request Query Parameter
Request BodyJSON object (bookmark attributes)
Response BodyJSON object (updated bookmark)
Response Status200

Update src/routes/bookmarks.js:

router.put("/bookmarks/:id", (req, res) => {
  const { id } = req.params;
  const { title, url } = req.body;
  const bookmarks = bookmarkDao.update({ id, title, url });
  res.json({
    status: 200,
    message: `Successfully updated the following bookmark!`,
    data: bookmarks,
  });
});

Save the code and commit the changes. Then, test this endpoint in Postman.

Untitled